#ifndef AVDEMUXER_H
#define AVDEMUXER_H
#include<QString>
#include<functional>
#include<memory>
#include<atomic>
#include<thread>


struct AVFormatContext;
class AVDeMuxer
{
public:
    AVDeMuxer();
    bool Open(const QString path);
    using StreamCallback = std::function<void(bool)>;
    inline void SetStreamCallback(const StreamCallback& cb){streamCb_=cb;};
            protected:
    void Close();
        void FetchStream(const QString path);
    bool FetchStrea1mInfo(const QString path);
        static int InterruptFountion(void* arg);
        private:
        int videoIndex =-1;
        int AudioIndex =-1;
        std::atomic_bool quit_=false;
        AVFormatContext* pFormatCtx_=nullptr;
        std::unique_ptr<std::thread>readThread_=nullptr;

        StreamCallback streamCb_=[](bool){};;
};
#endif // AVDEMUXER_H
